<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>shopcar</title>
		<!--购物车样式-->
		<link rel="stylesheet" type="text/css" href="./Public/Home/css/shopcar.css" />
		{{include file="VIEW_PATH/Common/header.php"}}
			<!--购物车主题-->
			<div id="shop-car-wrap">
				<div class="shop-jindu">
					<a href=""><img src="./Public/Home/img/snlogo.png"/></a>
					<div class="cart-progress">
						<ul>
							<li>
								<i class="juse">1</i>
									<div class="hengxian-shop">
							
									</div>
								<span>我的购物车</span>
							</li>
							<li>
								<i>2</i>
									<div class="hengxian-shop">
							
									</div>
								<span>确认订单</span>
							</li>
							<li>
								<i>3</i>
									<div class="hengxian-shop">
							
									</div>
								<span>付款</span>
							</li>
							<li>
								<i>4</i>
								<span>支付成功</span>
							</li>
						</ul>
						
					</div>
				</div>
				<div id="shop-main">
					<div class="shop-position">
						<span>送货到</span>
						<a href="">成都</a>
					</div>
					<!--全选商品，改变样式-->
					<script type="text/javascript">
						$(function(){
							
							
							var m = 1;
							$('.allChange').click(function(){
								
								m = m*-1;
								if(m == -1){
									$('.allChange').attr('checked','checked');
									
									$('.danChange').attr('checked','checked');
								}else{
									$('.allChange').removeAttr('checked');
									
									$('.danChange').removeAttr('checked');
								}
							})	
						})
					</script>
					<script type="text/javascript">
						$(function(){
							$('.danChange').click(function(){
//								判断是否全选，不是全选，将全选的状态去掉
								var lenAll = $('.danChange').size();
								var lenChecked = $('.danChange:checked').size();
								if(parseInt(lenChecked) < parseInt(lenAll)){
									$('.allChange').removeAttr('checked');
								}
							})
						})
					</script>
					<!--删除一个或者多个商品-->
					<script type="text/javascript">
						$(function(){
							$('.del_change').click(function(){
								var data = new Array();
								var len = $('.danChange:checked').length;
								var i = 0;
								$.each($('.danChange:checked'), function() {
									
									data[i] =  $('.danChange:checked').val();   
									$(this).parents('#shop-pro').remove();
									i++;
								});
//								alert(data);return;
								$.ajax({
									type:"post",
									url:"{{U('delChange')}}",
									data:{data:data},
									dataType:'json',
									success:function(phpData){
//										将传回来的商品总价，再赋值回去总价节点中去
//										总数
										$('.allNum').text('已选商品 ' + phpData.total_rows + '件');
//										总价										
										$('#totalPrice').text(phpData.totalPrice);
									}
									
								});
								
							})
							
						})
					</script>
					
					
					<div id="shopcar-title">
						<div class="shopcar-title1">
							<!--公用选择框-->
							<!--<div class="shopcar-btn allChange">
							</div>-->
							<input class="shopcar-btn allChange" type="checkbox" name="" id="" value="" />
							<span>全选</span>
						</div>
						<div  class="shopcar-title2">
							商品信息
						</div>
						<div  class="shopcar-title3">
							规格
						</div>
						<div  class="shopcar-title4">
							单价（元）
						</div>
						<div  class="shopcar-title5">
							数量
						</div>
						<div  class="shopcar-title6">
							小计
						</div>
						<div  class="shopcar-title7">
							操作
						</div>
						
					</div>
					{{if value="!empty($data['goods'])"}}
					<form action="{{U('Confirm/index')}}" method="post">
					<!--第一个购物车-->
					<?php $i=-1; ?>
					{{foreach from="$data['goods']" key="$k" value="$v"}}
					<?php $i++; ?>
					<div id="shop-pro">
						<input type="hidden" name="key" class="key" value="<?php echo $i; ?>" />
						<!--将$k存储到一个隐藏框里-->
						<input type="hidden" name="dataKey" class="dataKey" value="{{$k}}" />
						<!--此处引入c店铺标头，不过做功能好像用不到-->
						<div class="store-titel">
							<div class="store-titel-left fl">
								<div class="shopcar-btn">
								</div>
								<span>苏宁自营</span>
							</div>
							<div class="store-titel-right fr">
								<span>运费<i>￥0.00</i></span>
							</div>
						</div>
						<div class="store-main">
							<div class="chk-from">
								<input class="shopcar-btn danChange" type="checkbox" name="glid[]" value="{{$k}}" />
							</div>
							<div class="chk-item">
								<img src="{{$v['options']['listImg']}}"/>
								<a href="">
{{$v['name']}}
</a>
							</div>
							<div class="chk-space" style="width: 123px;">
								{{foreach from="$v['combileArr']" key="$kk" value="$vv"}}
								<p><strong>{{$kk}}</strong>&nbsp;:&nbsp; <span>{{$vv}}</span></p>
								{{endforeach}}
							</div>
							<div class="chk-price chk-dan" style="width: 86px;">
								<span>￥<strong class="priceAll1">{{$v['price']}}</strong>.00</span>
							</div>
							<div class="chk-amount">
								<div class="jiajianqi">
									<a href="javascript:;" class="jian">-</a>
									<input type="text" name="" class="pro-num" value="{{$v['num']}}" />
									<a class="jia" href="javascript:;">+</a>
								</div>
							</div>
							<div class="chk-num">
								<span>￥<strong class="priceAll">{{$v['total']}}</strong>.00</span>
							</div>
							<div class="chk-op">
								<a href="">移入收藏</a>
								<a class="delCartOne" href='javascript: ;'>删除</a>
								<a href="{{U('List/index',array('cid' => $v['cid']))}}">查找相似</a>
							</div>
						</div>
					</div>
					{{endforeach}}
					{{else}}
					<p>购物车没有商品，赶紧去购物吧！</p>
					{{endif}}
					
					
					<!--前台页面动态改变购买数量开始-->
					<script type="text/javascript">
						$(function(){
							var num = $('.key:last').attr('value');
							for(var i=0;i <= num; i++){
	//							单价
								var priceAll11 = $('.priceAll1').eq(i).text();
//								alert(priceAll11);
	//							总价在页面刷新的时候就改变
								proNow1 = $('.pro-num').eq(i).attr("value");
								proAll1 = parseInt(priceAll11) * parseInt(proNow1);
	//							总的价格得到
								$('.priceAll').eq(i).text(proAll1);	
							}

							
							$(".jian").click(function(){
								
//								获取单价
								var priceDan = $(this).parents('.chk-amount').siblings('.chk-dan').find('.priceAll1').html();
//								alert(priceDan); return;
								var pro = parseInt($(this).siblings('.pro-num').attr("value"));
//								alert(pro); return;
								if(pro <= 1){return;}
//											alert(pro);
								var new_pro = pro - 1;
								$(this).siblings('.pro-num').attr("value",new_pro);
							})
							$(".jia").click(function(){
								
//								获取单价
								var priceDan = $(this).parents('.chk-amount').siblings('.chk-dan').find('.priceAll1').html();
//								alert(priceDan); return;
								var pro = parseInt($(this).siblings('.pro-num').attr("value"));
//								alert(pro); return;
//											alert(pro);
								var new_pro = pro + 1;
								$(this).siblings('.pro-num').attr("value",new_pro);
							})
						})
					</script>
					<!--前台页面动态改变购买数量结束-->
					<!--将购买数量添加到session里面去开始-->
					<script type="text/javascript">
						$(function(){
							$('.jia').click(function(){
								var This = $(this);
								var proNum = $(this).siblings('.pro-num').val();
								var dataKey = $(this).parents('#shop-pro').find('.dataKey').val();
								
								$.ajax({
									type:"post",
									url:"{{U('changeNum')}}",
									data:{dataKey:dataKey,proNum:proNum},
									dataType:"Json",
									success:function(phpData){
										
//										将传回来的商品总价，再赋值回去总价节点中去
//										单个的总价
										This.parents('.store-main').find('.priceAll').text(phpData.totalOne);
//										总数
										$('.allNum').text('已选商品 ' + phpData.total_rows + '件');
//										总价										
										$('#totalPrice').text(phpData.totalPrice);
									}
								});	
								
							})
							
							$('.jian').click(function(){
								var This = $(this);
								var proNum = $(this).siblings('.pro-num').val();
								var dataKey = $(this).parents('#shop-pro').find('.dataKey').val();
								
								$.ajax({
									type:"post",
									url:"{{U('changeNum')}}",
									data:{dataKey:dataKey,proNum:proNum},
									dataType:"Json",
									success:function(phpData){
										
//										将传回来的商品总价，再赋值回去总价节点中去
//										单个的总价
										This.parents('.store-main').find('.priceAll').text(phpData.totalOne);
//										总数
										$('.allNum').text('已选商品 ' + phpData.total_rows + '件');
//										总价										
										$('#totalPrice').text(phpData.totalPrice);
									}
								});	
								
							})
							
						})
					</script>
					<!--删除-->
					<script type="text/javascript">
						$(function(){
							$('.delCartOne').click(function(){
								var This = $(this);
								var proNum = 0;
								var dataKey = $(this).parents('#shop-pro').find('.dataKey').val();
//								将当前元素的祖父节点删除
								$(this).parents('#shop-pro').remove();
								
								$.ajax({
									type:"post",
									url:"{{U('delOne')}}",
									data:{dataKey:dataKey,proNum:proNum},
									dataType:"Json",
									success:function(phpData){
										
//										将传回来的商品总价，再赋值回去总价节点中去
//										总数
										$('.allNum').text('已选商品 ' + phpData.total_rows + '件');
//										总价										
										$('#totalPrice').text(phpData.totalPrice);
									}
								});	
								
							})
						})
					</script>
					
					<!--将购买数量添加到session里面去结束-->
					
					
					<!--下面是复制上面的-->	
					<div id="shop-pro">
						<!--此处引入c店铺标头，不过做功能好像用不到-->
						<div class="store-titel">
							<div class="store-titel-left fl">
								<div class="shopcar-btn">
								</div>
								<span>换啥酒店专访</span>
							</div>
							<div class="store-titel-right fr">
								<span>运费<i>￥0.00</i></span>
							</div>
						</div>
						<div class="store-main">
							<div class="chk-from">
								<div class="shopcar-btn">
								</div>
							</div>
							<div class="chk-item">
								<img src="./Public/Home/img/shopcar/000000000133377680_1_400x400.jpg"/>
								<a href="">
绍兴特产 绍兴黄酒 女儿红坛装黄酒 三年陈花雕酒 1.5L陶坛
</a>
							</div>
							<div class="chk-space">
								
							</div>
							<div class="chk-price">
								<span>￥33.00</span>
							</div>
							<div class="chk-amount">
								<div class="jiajianqi">
									<a href="">-</a>
									<input type="text" name="" id="" value="1" />
									<a class="jia" href="">+</a>
								</div>
							</div>
							<div class="chk-num">
								<span>￥33.00</span>
							</div>
							<div class="chk-op">
								<a href="">移入收藏</a>
								<a href="">删除</a>
								<a href="">查找相似</a>
							</div>
						</div>
					</div>
					
					<!--结算购物条开始-->
					<div id="toolbar-box">
						<div class="toolbar-box-left fl">
							<!--公用选择框-->
							<!--<div class="shopcar-btn allChange">-->
							<!--</div>-->
							<input  class="shopcar-btn allChange" type="checkbox" name="" id="" value="" />
							<span>全选</span>
							<a href="javascript:;" class="del_change">删除选中商品</a>
						</div>
						
						<div class="toolbar-box-centent fl">
							{{if value="is_array($data) && !empty($data)"}}
							<span class="allNum">已选商品 {{$data['total_rows']}}件</span>
							{{else}}
							<span class="allNum">已选商品 0件</span>
							{{endif}}
						</div>
						<div class="jiesuan fr">
							<!--<a href="{{U('Confirm/index')}}">结算</a>-->
							<input type="submit" value="结算" />
						</div>
						</form>
						<div class="toolbar-box-right fr">
							{{if value="is_array($data) && !empty($data)"}}
							<p> 总价（含运费）：<span>¥<strong id="totalPrice">{{$data['total']}}</strong></span></p>
							<p>
							{{else}}
							<p> 总价（含运费）：<span>¥<strong id="totalPrice">0</strong></span></p>
							<p>
							{{endif}}
							
									<em class="fl">为您节省：¥0.00</em> 
								
								
									<em class="fr">运费（以结算页为准）：¥0.00</em>
						
							</p>
						</div>
					</div>
					
					
					
					<!--结算结束-->
				</div>
			</div>
			
			
			
			<!--购物车结束-->
			{{include file="VIEW_PATH/Common/footer.php"}}
</body>
</html>